package lagou.mode3.mode4;

import java.io.File;

public class DeleteDirectory {
    public static void main(String[] args) {
        String pathname="e:/壁纸";
        File file = new File(pathname);
        delete(file);
        System.out.println(pathname+"目录下的所有内容均已被删除。");

    }
    public static void delete(File file){
        if(file.isDirectory()) {
            File[] files = file.listFiles();
            for (File ft : files) {
                if (ft.isFile()) {
                    ft.delete();
                }
                if(ft.isDirectory()){
                    delete(ft);
                }
            }
            file.delete();
        }
    }
}
